Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

neofetch: add support for OSH #1442

Merged
merged 6 commits into from
Apr 16, 2020
Merged

neofetch: add support for OSH #1442

merged 6 commits into from
Apr 16, 2020

Conversation

Crestwave
Copy link
Contributor

@Crestwave Crestwave commented Apr 16, 2020

Not sure if it should use the current $OIL_VERSION if it exists and if $BASH_VERSION should only be set if the $SHELL is bash.

@Crestwave
Copy link
Contributor Author

Crestwave commented Apr 16, 2020

Actually, $bash_version might be unnecessary, unless I'm missing something (if so, just discard that commit). But it might be messy to set BASH_VERSINFO to an array with just a single element in OSH...

neofetch Outdated
Comment on lines 33 to 38
if [[ "${BASH_VERSINFO[0]}" ]]; then
bash_version=${BASH_VERSINFO[0]}
else
bash_version=5
shopt -s eval_unsafe_arith
fi
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably easier to just do bash_version=${BASH_VERSINFO[0]:-5} and then run the shopt with &>/dev/null (always).

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question, will it be difficult for us to remove the shopt entirely? What needs to be done?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually haven't had any issues without it, but I noticed that you do an unset -v "gpus[0]" on a certain condition in the script, which is invalid in OSH without eval_unsafe_arith.

Comment on lines +33 to +34
bash_version=${BASH_VERSINFO[0]:-5}
shopt -s eval_unsafe_arith &>/dev/null
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# Fallback to a value of '5' for shells which support bash
# but do not set the 'BASH_' shell variables (osh). 
bash_version=${BASH_VERSINFO[0]:-5}
shopt -s eval_unsafe_arith &>/dev/null

Copy link
Contributor Author

@Crestwave Crestwave Apr 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that I actually set BASH_VERSION later on. I could probably use shell+=$BASH_VERSION; shell=${shell/-*} instead

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, that doesn't make sense. At all.

Copy link
Contributor Author

@Crestwave Crestwave Apr 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I think what I was going for was:

if [[ $BASH_VERSION ]]; then
    shell+=$("$SHELL" -c "printf %s \"\$BASH_VERSION\"")
else
    shell+=$BASH_VERSION
fi
shell=${shell/-*}

Copy link
Contributor Author

@Crestwave Crestwave Apr 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or actually, something like:

shell+=${BASH_VERSION:-$("$SHELL" -c "printf %s \"\$BASH_VERSION\"")}
shell=${shell/-*}

But if you're fine with that, then cool

@dylanaraps dylanaraps merged commit d2ca250 into dylanaraps:master Apr 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants